import math
import operator
import os
import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict, namedtuple
from functools import cmp_to_key, reduce
from heapq import heappush, heappop, heapify
from io import IOBase, BytesIO
from itertools import accumulate, product, permutations
from operator import xor
from random import randint
from sys import api_version, prefix
from typing import Iterable, Iterator, Generic, TypeVar, List, Union, Optional
from unicodedata import decimal

read_from_file, de, useDfs = 0, 0, 1

if useDfs:
    from types import GeneratorType


    def bootstrap(f, stack=[]):
        def wrappedfunc(*args, **kwargs):
            if stack:
                return f(*args, **kwargs)
            else:
                to = f(*args, **kwargs)
                while True:
                    if type(to) is GeneratorType:
                        stack.append(to)
                        to = next(to)
                    else:
                        stack.pop()
                        if not stack:
                            break
                        to = stack[-1].send(to)
                return to

        return wrappedfunc

if 1:
    BUFSIZE = 4096


    class IOWrapper(IOBase):
        def __init__(self, file):
            self.buffer = FastIO(file)
            self.flush = self.buffer.flush
            self.writable = self.buffer.writable
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


    class FastIO(IOBase):
        newlines = 0

        def __init__(self, file):
            self._fd = file.fileno()
            self.buffer = BytesIO()
            self.writable = "x" in file.mode or "r" not in file.mode
            self.write = self.buffer.write if self.writable else None

        def readline(self):
            while self.newlines == 0:
                b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
                self.newlines = b.count(b"\n") + (not b)
                ptr = self.buffer.tell()
                self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
            self.newlines -= 1
            return self.buffer.readline()

        def flush(self):
            if self.writable:
                os.write(self._fd, self.buffer.getvalue())
                self.buffer.truncate(0), self.buffer.seek(0)

        def read(self):
            while True:
                b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
                if not b:
                    break
                ptr = self.buffer.tell()
                self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
            self.newlines = 0
            return self.buffer.read()


    sys.stdin = IOWrapper(sys.stdin)
    sys.stdout = IOWrapper(sys.stdout)
    input = lambda: sys.stdin.readline().rstrip("\r\n")


    def I():
        return input()


    def ii():
        return int(input())


    def li():
        return list(input().split())


    def mi():
        return map(int, input().split())


    def lii():
        return list(map(int, input().split()))


    def gmi():
        return map(lambda x: int(x) - 1, input().split())


    def lgmi():
        return list(map(lambda x: int(x) - 1, input().split()))


    fmax = lambda x, y: x if x > y else y
    fmin = lambda x, y: x if x < y else y

if read_from_file:
    fin = open('std/input.txt', 'r')
    input = lambda: fin.readline().strip()
    output_file = open("std/output.txt", "w")


    def fprint(*args, **kwargs):
        print(*args, **kwargs, file=output_file)


class MaxNumArray:
    def __init__(self, n):
        self.n = n
        self.tree = [0] * (2 * n)

    def update(self, pos, val):
        pos += self.n
        self.tree[pos] = math.gcd(val,self.tree[pos])
        while pos:
            l = r = pos
            if pos % 2 == 0:
                r = pos + 1
            else:
                l = pos - 1
            self.tree[pos // 2] = math.gcd(self.tree[l], self.tree[r])
            pos //= 2

    def maxRange(self, l, r):
        l += self.n
        r += self.n
        ans = 0
        while l <= r:
            if l & 1:
                ans = math.gcd(ans, self.tree[l])
                l += 1
            if (r & 1) == 0:
                ans = math.gcd(ans, self.tree[r])
                r -= 1
            l //= 2
            r //= 2
        return ans
for _ in range(ii()):
    n,q = mi()
    nums = lii()
    st = MaxNumArray(n + 1)
    for i in range(1,n):
        st.update(i,nums[i] - nums[i - 1])
    ans = []
    for _ in range(q):
        l,r = mi()
        v = st.maxRange(l,r - 1)
        ans.append(v)
    print(*ans)


